;
; FARLFUNC.SH Version 1.00 (C)1996 HUDSON SOFT
; HuC6273操作ライブラリ アセンブラ用ヘッダーファイル(FARLFUNC.SH)
;
	ifndef	_FARLFUNC_SH_
_FARLFUNC_SH_	equ	1

;************************************************************************
;*   Function Defintions 
;************************************************************************

;
; Base functions
;
	globl	FarlInit
	globl	FarlWriteFifoH
	globl	FarlWriteFifoW
	globl	FarlWriteFifoHA
	globl	FarlWriteFifoWA
	globl	FarlSetPEReg
	globl	FarlSetTEReg
	globl	FarlReset
	globl	FarlGetTEReg
	globl	FarlGetPEReg
	globl	FarlWriteTxt
	globl	FarlWriteTxtUnpk
	globl	FarlWriteTxtXY
	globl	FarlWriteTxtXYUnpk
	globl	FarlSetLut
	globl	FarlGetLut

;************************************************************************
;*   Parameter Defintions 
;************************************************************************

FARL_SET_LIGHT1	equ	1	; Set light vector 1
FARL_SET_LIGHT2	equ	2	; Set light vector 2
	globl	FarlSetLight

;
; Primitive functions
;
;************************************************************************
;*   Type Defintions 
;************************************************************************
FARL_GTYPE_VC	equ	$000	; Vertex color, w.o. normal
FARL_GTYPE_VCVN	equ	$100	; Vertex color, Vertex normal
FARL_GTYPE_FCFN	equ	$200	; Facet color, Facet normal
FARL_GTYPE_TX	equ	$400	; Texture map, w.o. normal
FARL_GTYPE_TXVN	equ	$500	; Texture map, Vertex normal
FARL_GTYPE_TXFN	equ	$600	; Texture map, Facet normal
FARL_GTYPE_DC	equ	$800	; Default color, w.o. normal
FARL_GTYPE_DCVN	equ	$900	; Default color, Vertex normal
FARL_GTYPE_DCFN	equ	$a00	; Default color, Facet normal

	globl	FarlPutImage
	globl	FarlPutDZImage
	globl	FarlPutTextureImage
	globl	FarlFillBuffer
	globl	FarlTriangleStrip
	globl	FarlTriangleList
	globl	FarlPolyLine
	globl	FarlLineList
	globl	FarlPointList

;
; Command functions
;
	globl	FarlReadPixelDZ
	globl	FarlReadPixelTxt

;
; TE register functions
;
	globl	FarlSetLightCoef
	globl	FarlSetLight1
	globl	FarlSetLight2
	globl	FarlSetTEMeshPatternReg
	globl	FarlSetSrcMatrix
	globl	FarlSetSrcMatrix3x3
	globl	FarlSetSrcMatrix3x1
	globl	FarlSetSrcMatrix6
	globl	FarlSetTEControlReg
	globl	FarlSetWindowClipReg
	globl	FarlSetWindowScaleReg
	globl	FarlSetTEObjMatrix
	globl	FarlSetTENrmMatrix
	globl	FarlSetUVOffsetReg
	globl	FarlSetDefColorReg

;
; PE register functions 
;
	globl	FarlSetPEClearTextureReg
	globl	FarlSetPEClearZReg
	globl	FarlSetPEClearColorReg
	globl	FarlSetPEClearMaskReg
	globl	FarlSetPEFlashICReg
	globl	FarlSetPEFrameCtrlReg
	globl	FarlSetPEICMaskReg
	globl	FarlSetLut1
	globl	FarlSetLut2
	globl	FarlSetLut3
	globl	FarlSetPEControlReg
	globl	FarlSetPEMaskReg
	globl	FarlSetPETargetReg
	globl	FarlSetPETextureReg
	globl	FarlSetPECwtXOffReg
	globl	FarlSetPECwtYOffReg

;
; Matrix operation functions
;
	globl	FarlCopyDstToNrm
	globl	FarlCopyDstToObj
	globl	FarlCopyDstToRst
	globl	FarlCopyDstToSrc
	globl	FarlCopySrcToRst
	globl	FarlCopyRstToSrc
	globl	FarlCopyDstToLgt1
	globl	FarlCopyDstToLgt2
	globl	FarlMul3x3M1015
	globl	FarlMul4x4M1015
	globl	FarlMul3x3M187
	globl	FarlMul4x4M187
	globl	FarlMul3x1V1015
	globl	FarlTESync
	globl	FarlVertexTest

;
; Sprite support functions.
;
	globl	FarlSetSpControlTbl
	globl	FarlSetSpParamTbl
	globl	FarlSetSpWinClipReg
	globl	FarlSpriteGo
	globl	FarlSpbsySpin
	globl	FarlWaitSpdone
	globl	FarlClearSpdone

;
; CMT support functions.
;
	globl	FarlSetCmt
	globl	FarlCmtGo
	globl	FarlCmbsySpin
	globl	FarlCmpndSpin
	globl	FarlWaitCmdone
	globl	FarlClearCmdone

;
; Utility functions
;
	globl	FarlFixMul1015
	globl	FarlFixMul187
	globl	FarlPerseZ4x4M187
	globl	FarlRotateX3x3M1015
	globl	FarlRotateX4x4M187
	globl	FarlRotateY3x3M1015
	globl	FarlRotateY4x4M187
	globl	FarlRotateZ3x3M1015
	globl	FarlRotateZ4x4M187
	globl	FarlRotateXSC3x3M1015
	globl	FarlRotateYSC3x3M1015
	globl	FarlRotateZSC3x3M1015
	globl	FarlRotateXSC4x4M187
	globl	FarlRotateYSC4x4M187
	globl	FarlRotateZSC4x4M187
	globl	FarlTranslate4x4M187
	globl	FarlScale4x4M187
	globl	FarlSwapWindow
	globl	FarlSwapWindowH
	globl	FarlValidateSwap
	globl	FarlDummySwap
	globl	FarlSetUnitMatrix1015
	globl	FarlSetUnitMatrix187
	globl	FarlFix1015
	globl	FarlFix187
	globl	FarlFloat1015
	globl	FarlFloat187
	globl	FarlNormalizeVector
	globl	FarlGetSin187
	globl	FarlGetSin1015
	globl	FarlGetCos187
	globl	FarlGetCos1015
	globl	FarlCopyDstToMem4x4
	globl	FarlCopyDstToMem3x3
	globl	FarlCopyDstToMem3x1
	globl	FarlGetRotateX3x3M1015
	globl	FarlGetRotateY3x3M1015
	globl	FarlGetRotateZ3x3M1015
	globl	FarlGetRotateXSC3x3M1015
	globl	FarlGetRotateYSC3x3M1015
	globl	FarlGetRotateZSC3x3M1015
	globl	FarlGetRotateX4x4M187
	globl	FarlGetRotateY4x4M187
	globl	FarlGetRotateZ4x4M187
	globl	FarlGetRotateXSC4x4M187
	globl	FarlGetRotateYSC4x4M187
	globl	FarlGetRotateZSC4x4M187
	globl	FarlGetTranslate4x4M187
	globl	FarlGetScale4x4M187
	globl	FarlMatrixCopy3x3
	globl	FarlMatrixCopy4x4

;
; Get Command Packet Size Functions.
;
	globl	FarlGetTriangleStripSize
	globl	FarlGetTriangleListSize
	globl	FarlGetPolyLineSize
	globl	FarlGetLineListSize
	globl	FarlGetPointListSize
;
; Dump Vector Functions
;
	globl	FarlDumpTriangleStrip
	globl	FarlDumpTriangleList
	globl	FarlDumpPolyLine
	globl	FarlDumpLineList
	globl	FarlDumpPointList

;************************************************************************
;*   Type definitions
;************************************************************************
farl_conf_t	struct
tbwidth		ds	1
tsize		ds	1
revi		ds	1
		ends

	globl	FarlGetConf

;************************************************************************
;*   Function Macro Defintions 
;************************************************************************
	ifndef _LIBFARL_SH_
FarlInportB	macro	addr,reg
		mov	addr,at
		in.b	0(at),reg
		endm

FarlInportH	macro	addr,reg
		mov	addr,at
		in.h	0(at),reg
		endm

FarlInportW	macro	addr,reg
		mov	addr,at
		in.w	0(at),reg
		endm

FarlOutportB	macro	addr,data
		mov	addr,at
		mov	data,ut
		out.b	ut,0(at)
		endm

FarlOutportH	macro	addr,data
		mov	addr,at
		mov	data,ut
		out.h	ut,0(at)
		endm

FarlOutportW	macro	addr,data
		mov	addr,at
		mov	data,ut
		out.w	ut,0(at)
		endm

FarlSetMemReg	macro	addr, data
		mov	addr,at
		mov	data,ut
		out.h	ut,0(at)
		endm

FarlGetMemReg	macro	addr,reg
		mov	addr,at
		in.h	0(at),reg
		endm

	endif	; !_LIBFARL_SH_

	endif	; !_FARLFUNC_SH_
